/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.openbrew.openbrewrf;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author dchapman
 */
@Entity
@Table(name = "OBAlarm")
@XmlRootElement
public class OBAlarm implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "AlarmID")
    private Integer alarmID;
    @Basic(optional = false)
    @NotNull
    @Size(min = 0, max = 250)
    @Column(name = "AlarmText")
    private String alarmText;
    @Basic(optional = false)
    @NotNull
    @Column(name = "AlarmType")
    private int alarmType;
    @Basic(optional = false)
    @NotNull
    @Column(name = "AlarmHours")
    private int alarmHours;
    @OneToMany(cascade=CascadeType.REFRESH, fetch=FetchType.EAGER)
    @JoinTable(
        name="JTAlarmToEmp",
        joinColumns={ @JoinColumn(name="AlarmID", referencedColumnName="AlarmID")},
        inverseJoinColumns={ @JoinColumn(name="EmpID", referencedColumnName="EmpID", unique=true)}
    )
    private List<Employee> empCollection;

    public OBAlarm() {
    }

    public OBAlarm(Integer alarmID) {
        this.alarmID = alarmID;
    }

    public OBAlarm(Integer alarmID, String alarmText, int alarmType, int alarmHours) {
        this.alarmID = alarmID;
        this.alarmText = alarmText;
        this.alarmType = alarmType;
        this.alarmHours = alarmHours;
    }

    public Integer getAlarmID() {
        return alarmID;
    }

    public void setAlarmID(Integer alarmID) {
        this.alarmID = alarmID;
    }

    public String getAlarmText() {
        return alarmText;
    }

    public void setAlarmText(String alarmText) {
        this.alarmText = alarmText;
    }

    public int getAlarmType() {
        return alarmType;
    }

    public void setAlarmType(int alarmType) {
        this.alarmType = alarmType;
    }

    public int getAlarmHours() {
        return alarmHours;
    }

    public void setAlarmHours(int alarmHours) {
        this.alarmHours = alarmHours;
    }

    public List<Employee> getEmployeeCollection() {
        return empCollection;
    }

    public void setEmployeeCollection(List<Employee> empCollection) {
        this.empCollection = empCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (alarmID != null ? alarmID.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Movement)) {
            return false;
        }
        OBAlarm other = (OBAlarm) object;
        if ((this.alarmID == null && other.alarmID != null) || (this.alarmID != null && !this.alarmID.equals(other.alarmID))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.openbrew.openbrewrf.OBAlarm[ alarmID=" + alarmID + " ]";
    }
    
}
